<template>
<div>
    <div style="width: 300px;height: 100px;border: 1px black solid;">
        <p style="color: blue;">
        哥哥
    </p>

      <!-- <p>{{ b }}</p> -->

      <el-input v-model="b" placeholder="请输入" size="default" clearable ></el-input>
      

      <el-button type="primary" size="default" @click="send2dd">发给-弟弟</el-button>
      
    </div>
    
</div>
</template>
<script>
import bus from '@/utils/mittBus.js';
export default{
    data(){
        return{
            b:'123'
        }
    },
    methods:{
        send2dd(){
            console.log('--send2dd---',this.b)

            //发布mitt事件
            bus.emit('evtSend2dd',this.b)
        }
    },
    mounted(){
        //订阅mitt事件
        bus.on('evtSend2gg',(e)=>{
                console.log('bus-receive-from-dd-')

                console.log(e)
                this.b = e;

            });
    },
    beforeUnmount(){
        //off移除事件
        bus.off('evtSend2dd')

        //移除所有事件
        // bus.all.clear();
    }

}
</script>
<style>
</style>